package io.renren.modules.user.service.impl;

import io.renren.common.utils.R;
import io.renren.modules.user.dao.TPeopleCopyDao;
import io.renren.modules.user.entity.*;
import io.renren.modules.user.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.user.dao.TApplyDao;
import org.springframework.transaction.annotation.Transactional;


@Service("tApplyService")
public class TApplyServiceImpl extends ServiceImpl<TApplyDao, TApplyEntity> implements TApplyService {

    @Autowired
    private TAppplyProcessService tAppplyProcessService;
    @Autowired
    private TPeopleService tPeopleService;
    @Autowired
    private TPeopleNoticeService tPeopleNoticeService;
    @Autowired
    private  TApplyRecordService tApplyRecordService;
    @Autowired
    private TPeopleCopyService tPeopleCopyService;
    @Autowired
    private TPeopleCopyDao tPeopleCopyDao;
    @Autowired
    private TPeopleLogService tPeopleLogService;



    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<TApplyEntity> page = this.page(
                new Query<TApplyEntity>().getPage(params),
                new QueryWrapper<TApplyEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public R saveApply(TApplyEntity tApply) {
       // ArrayList arrayList=new ArrayList();
        this.save(tApply);
        //生成审批流程信息
        TAppplyProcessEntity tAppplyProcess=new TAppplyProcessEntity();
        tAppplyProcess.setFirstLevel("-1");
        tAppplyProcess.setCurrentLevel("1");
        tAppplyProcess.setEndLevel("0");
        tAppplyProcess.setApplyId(tApply.getId());
        tAppplyProcess.setApplyUser(1); //管理员角色
        tAppplyProcess.setState("0");
        tAppplyProcessService.save(tAppplyProcess);
        return R.ok();
    }

    @Override
    @Transactional
    public R updateApply(TApplyRecordEntity tApplyRecordEntity) {
        List<TApplyRecordEntity> tApplyRecordEntityList = tApplyRecordService.list(new QueryWrapper<TApplyRecordEntity>().eq("id", tApplyRecordEntity.getId()));
        TApplyRecordEntity tApplyEntity = tApplyRecordEntityList.get(0);
        if("1".equals(tApplyRecordEntity.getState())){ //通过
            //生成审批记录信息
            tApplyRecordEntity.setApplyTime(new Date());
            tApplyRecordEntity.setState("1");
            tApplyRecordService.updateById(tApplyRecordEntity);

            //修改人员信息
            //查询修改前的信息
            TPeopleEntity tPeopleEntity = tPeopleService.findPeople(tApplyEntity.getDataId());

            List<TPeopleCopyEntity> peopleList = tPeopleCopyService.list(new QueryWrapper<TPeopleCopyEntity>().eq("id", tApplyEntity.getDataId()));
            TPeopleCopyEntity tPeopleCopyEntity = peopleList.get(0);
            tPeopleCopyDao.updateByPrimaryKeySelective(tPeopleCopyEntity);

            TPeopleEntity findpeople = tPeopleCopyService.findpeople(tApplyEntity.getDataId() + "");
            //删除临时表信息
            tPeopleCopyDao.delete(new QueryWrapper<TPeopleCopyEntity>().eq("id", tApplyEntity.getDataId()));
            //插入通知表，提醒相关人员
            TPeopleNoticeEntity tPeopleNoticeEntity=new TPeopleNoticeEntity();
            tPeopleNoticeEntity.setPeopleId(tApplyEntity.getDataId());
            tPeopleNoticeEntity.setName(tApplyRecordEntity.getApplyUser());
            tPeopleNoticeEntity.setChanageAfterClasses("申请修改通过");
            tPeopleNoticeService.save(tPeopleNoticeEntity);
            //添加操作信息
            TPeopleLogEntity tPeopleLogEntity=new TPeopleLogEntity();
            if(null!=tPeopleCopyEntity.getDept() && !tPeopleCopyEntity.getDept().equals(tPeopleEntity.getDept())){
                tPeopleLogEntity.setFirstChanage("单位："+tPeopleEntity.getDetachment());
                tPeopleLogEntity.setEndChanage("单位："+findpeople.getDetachment());
                tPeopleLogEntity.setPeopleId(findpeople.getId());
                tPeopleLogEntity.setCreateUser(tApplyRecordEntity.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            }
            if(null !=tPeopleCopyEntity.getClasses() &&!tPeopleCopyEntity.getClasses().equals(tPeopleEntity.getClasses())) {
                tPeopleLogEntity.setFirstChanage("班组："+tPeopleEntity.getClassesName());
                tPeopleLogEntity.setEndChanage("班组："+findpeople.getClassesName());
                tPeopleLogEntity.setPeopleId(findpeople.getId());
                tPeopleLogEntity.setCreateUser(tApplyRecordEntity.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            }if(null !=tPeopleCopyEntity.getName() &&!tPeopleCopyEntity.getName().equals(tPeopleEntity.getName())) {
                tPeopleLogEntity.setFirstChanage("姓名："+tPeopleEntity.getName());
                tPeopleLogEntity.setEndChanage("姓名："+findpeople.getName());
                tPeopleLogEntity.setPeopleId(findpeople.getId());
                tPeopleLogEntity.setCreateUser(tApplyRecordEntity.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null!=tPeopleCopyEntity.getOldName() &&!tPeopleCopyEntity.getOldName().equals(tPeopleEntity.getOldName())) {
                tPeopleLogEntity.setFirstChanage("曾用命："+tPeopleEntity.getOldName());
                tPeopleLogEntity.setEndChanage("曾用命："+findpeople.getOldName());
                tPeopleLogEntity.setPeopleId(findpeople.getId());
                tPeopleLogEntity.setCreateUser(tApplyRecordEntity.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeopleCopyEntity.getSex() && !tPeopleCopyEntity.getSex().equals(tPeopleEntity.getSex())) {
                tPeopleLogEntity.setFirstChanage("性别："+tPeopleEntity.getSex());
                tPeopleLogEntity.setEndChanage("性别："+findpeople.getSex());
                tPeopleLogEntity.setPeopleId(findpeople.getId());
                tPeopleLogEntity.setCreateUser(tApplyRecordEntity.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeopleCopyEntity.getEthnic() &&!tPeopleCopyEntity.getEthnic().equals(tPeopleEntity.getEthnic())) {
                tPeopleLogEntity.setFirstChanage("民族："+tPeopleEntity.getMinName());
                tPeopleLogEntity.setEndChanage("民族："+findpeople.getMinName());
                tPeopleLogEntity.setPeopleId(findpeople.getId());
                tPeopleLogEntity.setCreateUser(tApplyRecordEntity.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeopleCopyEntity.getBirthday() &&!tPeopleCopyEntity.getBirthday().equals(tPeopleEntity.getBirthday())) {
                tPeopleLogEntity.setFirstChanage("生日："+tPeopleEntity.getBirthday());
                tPeopleLogEntity.setEndChanage("生日："+findpeople.getBirthday());
                tPeopleLogEntity.setPeopleId(findpeople.getId());
                tPeopleLogEntity.setCreateUser(tApplyRecordEntity.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeopleCopyEntity.getBround() &&!tPeopleCopyEntity.getBround().equals(tPeopleEntity.getBround())) {
                tPeopleLogEntity.setFirstChanage("籍贯："+tPeopleEntity.getBround());
                tPeopleLogEntity.setEndChanage("籍贯："+findpeople.getBround());
                tPeopleLogEntity.setPeopleId(findpeople.getId());
                tPeopleLogEntity.setCreateUser(tApplyRecordEntity.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeopleCopyEntity.getIdcard() &&!tPeopleCopyEntity.getIdcard().equals(tPeopleEntity.getIdcard())) {
                tPeopleLogEntity.setFirstChanage("身份证："+tPeopleEntity.getIdcard());
                tPeopleLogEntity.setEndChanage("身份证："+findpeople.getIdcard());
                tPeopleLogEntity.setPeopleId(findpeople.getId());
                tPeopleLogEntity.setCreateUser(tApplyRecordEntity.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeopleCopyEntity.getWorkidcard() &&!tPeopleCopyEntity.getWorkidcard().equals(tPeopleEntity.getWorkidcard())) {
                tPeopleLogEntity.setFirstChanage("工作证："+tPeopleEntity.getWorkidcard());
                tPeopleLogEntity.setEndChanage("工作证："+findpeople.getWorkidcard());
                tPeopleLogEntity.setPeopleId(findpeople.getId());
                tPeopleLogEntity.setCreateUser(tApplyRecordEntity.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeopleCopyEntity.getDutytime() &&!tPeopleCopyEntity.getDutytime().equals(tPeopleEntity.getDutytime())) {
                tPeopleLogEntity.setFirstChanage("入职时间："+tPeopleEntity.getDutytime());
                tPeopleLogEntity.setEndChanage("入职时间："+findpeople.getDutytime());
                tPeopleLogEntity.setPeopleId(findpeople.getId());
                tPeopleLogEntity.setCreateUser(tApplyRecordEntity.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            }
            if(null !=tPeopleCopyEntity.getTitleType() &&!tPeopleEntity.getTitleType().equals(tPeopleCopyEntity.getTitleType())) {
            tPeopleLogEntity.setFirstChanage("衔级类别："+tPeopleEntity.getTitleType());
            tPeopleLogEntity.setEndChanage("衔级类别："+findpeople.getTitleType());
            tPeopleLogEntity.setPeopleId(findpeople.getId());
            tPeopleLogEntity.setCreateUser(tApplyRecordEntity.getCreateUser());
            tPeopleLogEntity.setCreateTime(new Date());
            tPeopleLogService.save(tPeopleLogEntity);
        }
            if(tPeopleCopyEntity.getTitle()!=null  &&!tPeopleCopyEntity.getTitle().equals(tPeopleEntity.getTitle())) {

                tPeopleLogEntity.setFirstChanage("衔级："+tPeopleEntity.getTitleName());
                tPeopleLogEntity.setEndChanage("衔级："+findpeople.getTitleName());
                tPeopleLogEntity.setPeopleId(findpeople.getId());
                tPeopleLogEntity.setCreateUser(tApplyRecordEntity.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            }
            if(null!=tPeopleCopyEntity.getTitleTime() &&!tPeopleCopyEntity.getTitleTime().equals(tPeopleEntity.getTitleTime())) {
                tPeopleLogEntity.setFirstChanage("当前衔级时间："+tPeopleEntity.getTitleTime());
                tPeopleLogEntity.setEndChanage("当前衔级时间："+findpeople.getTitleTime());
                tPeopleLogEntity.setPeopleId(findpeople.getId());
                tPeopleLogEntity.setCreateUser(tApplyRecordEntity.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            }
            if(null!=tPeopleCopyEntity.getDutyPost() &&!tPeopleCopyEntity.getDutyPost().equals(tPeopleEntity.getDutyPost())) {
                tPeopleLogEntity.setFirstChanage("专业岗位："+tPeopleEntity.getGname());
                tPeopleLogEntity.setEndChanage("专业岗位："+findpeople.getGname());
                tPeopleLogEntity.setPeopleId(findpeople.getId());
                tPeopleLogEntity.setCreateUser(tApplyRecordEntity.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null!=tPeopleCopyEntity.getDutyPostTime() &&!tPeopleCopyEntity.getDutyPostTime().equals(tPeopleEntity.getDutyPostTime())) {
                tPeopleLogEntity.setFirstChanage("当前岗位时间："+tPeopleEntity.getDutyPostTime());
                tPeopleLogEntity.setEndChanage("当前岗位时间："+findpeople.getDutyPostTime());
                tPeopleLogEntity.setPeopleId(findpeople.getId());
                tPeopleLogEntity.setCreateUser(tApplyRecordEntity.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            }
        if(null !=tPeopleCopyEntity.getFirePost() &&!tPeopleEntity.getFirePost().equals(tPeopleCopyEntity.getFirePost())) {
            tPeopleLogEntity.setFirstChanage("消防职务："+tPeopleEntity.getFirePost());
            tPeopleLogEntity.setEndChanage("消防职务："+findpeople.getFirePost());
            tPeopleLogEntity.setPeopleId(findpeople.getId());
            tPeopleLogEntity.setCreateUser(tApplyRecordEntity.getCreateUser());
            tPeopleLogEntity.setCreateTime(new Date());
            tPeopleLogService.save(tPeopleLogEntity);
        } if(null !=tPeopleCopyEntity.getFirePostTime() &&!tPeopleEntity.getFirePostTime().equals(tPeopleCopyEntity.getFirePostTime())) {
            tPeopleLogEntity.setFirstChanage("消防职务任职时间"+tPeopleEntity.getFirePostTime());
            tPeopleLogEntity.setEndChanage("消防职务任职时间"+findpeople.getFirePostTime());
            tPeopleLogEntity.setPeopleId(findpeople.getId());
            tPeopleLogEntity.setCreateUser(tApplyRecordEntity.getCreateUser());
            tPeopleLogEntity.setCreateTime(new Date());
            tPeopleLogService.save(tPeopleLogEntity);
        }
            if(null!=tPeopleCopyEntity.getFirePostClass() &&!tPeopleCopyEntity.getFirePostClass().equals(tPeopleEntity.getFirePostClass())) {
                tPeopleLogEntity.setFirstChanage("职务等级："+tPeopleEntity.getName7());
                tPeopleLogEntity.setEndChanage("职务等级："+findpeople.getName7());
                tPeopleLogEntity.setPeopleId(findpeople.getId());
                tPeopleLogEntity.setCreateUser(tApplyRecordEntity.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            }
            if(null!=tPeopleCopyEntity.getFireClassTime()&&!tPeopleCopyEntity.getFireClassTime().equals(tPeopleEntity.getFireClassTime())) {
                tPeopleLogEntity.setFirstChanage("职务年月："+tPeopleEntity.getFireClassTime());
                tPeopleLogEntity.setEndChanage("职务年月："+findpeople.getFireClassTime());
                tPeopleLogEntity.setPeopleId(findpeople.getId());
                tPeopleLogEntity.setCreateUser(tApplyRecordEntity.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            }
         if(null !=tPeopleCopyEntity.getTecPost() &&!tPeopleEntity.getTecPost().equals(tPeopleCopyEntity.getTecPost())) {
            tPeopleLogEntity.setFirstChanage("技术职务"+tPeopleEntity.getTecPost());
            tPeopleLogEntity.setEndChanage("技术职务"+findpeople.getTecPost());
            tPeopleLogEntity.setPeopleId(findpeople.getId());
            tPeopleLogEntity.setCreateUser(tApplyRecordEntity.getCreateUser());
            tPeopleLogEntity.setCreateTime(new Date());
            tPeopleLogService.save(tPeopleLogEntity);
        } if(null !=tPeopleCopyEntity.getTecPostTime() &&!tPeopleEntity.getTecPostTime().equals(tPeopleCopyEntity.getTecPostTime())) {
            tPeopleLogEntity.setFirstChanage("技术职务时间"+tPeopleEntity.getTecPostTime());
            tPeopleLogEntity.setEndChanage("技术职务时间"+findpeople.getTecPostTime());
            tPeopleLogEntity.setPeopleId(findpeople.getId());
            tPeopleLogEntity.setCreateUser(tApplyRecordEntity.getCreateUser());
            tPeopleLogEntity.setCreateTime(new Date());
            tPeopleLogService.save(tPeopleLogEntity);
        }
            if(null !=tPeopleCopyEntity.getTecClass() &&!tPeopleCopyEntity.getTecClass().equals(tPeopleEntity.getTecClass())) {
                tPeopleLogEntity.setFirstChanage("技术等级："+tPeopleEntity.getTecClass());
                tPeopleLogEntity.setEndChanage("技术等级："+findpeople.getTecClass());
                tPeopleLogEntity.setPeopleId(findpeople.getId());
                tPeopleLogEntity.setCreateUser(tApplyRecordEntity.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null!=tPeopleCopyEntity.getTecClassTime() &&!tPeopleCopyEntity.getTecClassTime().equals(tPeopleEntity.getTecClassTime())) {
                tPeopleLogEntity.setFirstChanage("技术等级年月："+tPeopleEntity.getTecClassTime());
                tPeopleLogEntity.setEndChanage("技术等级年月："+findpeople.getTecClassTime());
                tPeopleLogEntity.setPeopleId(findpeople.getId());
                tPeopleLogEntity.setCreateUser(tApplyRecordEntity.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null!=tPeopleCopyEntity.getAdministration() &&!tPeopleCopyEntity.getAdministration().equals(tPeopleEntity.getAdministration())) {
                tPeopleLogEntity.setFirstChanage("行政职务："+tPeopleEntity.getXname());
                tPeopleLogEntity.setEndChanage("行政职务："+findpeople.getXname());
                tPeopleLogEntity.setPeopleId(findpeople.getId());
                tPeopleLogEntity.setCreateUser(tApplyRecordEntity.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            }
            if(null!=tPeopleCopyEntity.getAdministrationTime() &&!tPeopleCopyEntity.getAdministrationTime().equals(tPeopleEntity.getAdministrationTime())) {
                tPeopleLogEntity.setFirstChanage("行政职务时间："+tPeopleEntity.getAdministrationTime());
                tPeopleLogEntity.setEndChanage("行政职务时间："+findpeople.getAdministrationTime());
                tPeopleLogEntity.setPeopleId(findpeople.getId());
                tPeopleLogEntity.setCreateUser(tApplyRecordEntity.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeopleCopyEntity.getHousehold() &&!tPeopleCopyEntity.getHousehold().equals(tPeopleEntity.getHousehold())) {
                tPeopleLogEntity.setFirstChanage("户籍："+tPeopleEntity.getHousehold());
                tPeopleLogEntity.setEndChanage("户籍："+findpeople.getHousehold());
                tPeopleLogEntity.setPeopleId(findpeople.getId());
                tPeopleLogEntity.setCreateUser(tApplyRecordEntity.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeopleCopyEntity.getRegisterType() &&!tPeopleCopyEntity.getRegisterType().equals(tPeopleEntity.getRegisterType())) {
                tPeopleLogEntity.setFirstChanage("户口类型："+tPeopleEntity.getRegisterType());
                tPeopleLogEntity.setEndChanage("户口类型："+findpeople.getRegisterType());
                tPeopleLogEntity.setPeopleId(findpeople.getId());
                tPeopleLogEntity.setCreateUser(tApplyRecordEntity.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeopleCopyEntity.getInvitationHousehold() &&!tPeopleCopyEntity.getInvitationHousehold().equals(tPeopleEntity.getInvitationHousehold())) {
                tPeopleLogEntity.setFirstChanage("招录前户籍："+tPeopleEntity.getInvitationHousehold());
                tPeopleLogEntity.setEndChanage("招录前户籍："+findpeople.getInvitationHousehold());
                tPeopleLogEntity.setPeopleId(findpeople.getId());
                tPeopleLogEntity.setCreateUser(tApplyRecordEntity.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeopleCopyEntity.getInvitationRegister() &&!tPeopleCopyEntity.getInvitationRegister().equals(tPeopleEntity.getInvitationRegister())) {
                tPeopleLogEntity.setFirstChanage("招录前户籍类型："+tPeopleEntity.getInvitationRegister());
                tPeopleLogEntity.setEndChanage("招录前户籍类型："+findpeople.getInvitationRegister());
                tPeopleLogEntity.setPeopleId(findpeople.getId());
                tPeopleLogEntity.setCreateUser(tApplyRecordEntity.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeopleCopyEntity.getInvitation() &&!tPeopleCopyEntity.getInvitation().equals(tPeopleEntity.getInvitation())) {
                tPeopleLogEntity.setFirstChanage("招录地省："+tPeopleEntity.getInvitation());
                tPeopleLogEntity.setEndChanage("招录地省："+findpeople.getInvitation());
                tPeopleLogEntity.setPeopleId(findpeople.getId());
                tPeopleLogEntity.setCreateUser(tApplyRecordEntity.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            }
        if(null !=tPeopleCopyEntity.getInvitation2() &&!tPeopleEntity.getInvitation2().equals(tPeopleCopyEntity.getInvitation2())) {
            tPeopleLogEntity.setFirstChanage("招录地市"+tPeopleEntity.getInvitation2());
            tPeopleLogEntity.setEndChanage("招录地市"+findpeople.getInvitation2());
            tPeopleLogEntity.setPeopleId(findpeople.getId());
            tPeopleLogEntity.setCreateUser(tApplyRecordEntity.getCreateUser());
            tPeopleLogEntity.setCreateTime(new Date());
            tPeopleLogService.save(tPeopleLogEntity);
        }
            if(null !=tPeopleCopyEntity.getPolitical() &&!tPeopleCopyEntity.getPolitical().equals(tPeopleEntity.getPolitical())) {
                tPeopleLogEntity.setFirstChanage("政治面貌："+tPeopleEntity.getPolitical());
                tPeopleLogEntity.setEndChanage("政治面貌："+findpeople.getPolitical());
                tPeopleLogEntity.setPeopleId(findpeople.getId());
                tPeopleLogEntity.setCreateUser(tApplyRecordEntity.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeopleCopyEntity.getPoliTime() &&!tPeopleCopyEntity.getPoliTime().equals(tPeopleEntity.getPoliTime())) {
                tPeopleLogEntity.setFirstChanage("入党时间："+tPeopleEntity.getPoliTime());
                tPeopleLogEntity.setEndChanage("入党时间："+findpeople.getPoliTime());
                tPeopleLogEntity.setPeopleId(findpeople.getId());
                tPeopleLogEntity.setCreateUser(tApplyRecordEntity.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeopleCopyEntity.getEducation() &&!tPeopleCopyEntity.getEducation().equals(tPeopleEntity.getEducation())) {
                tPeopleLogEntity.setFirstChanage("文化程度："+tPeopleEntity.getEducation());
                tPeopleLogEntity.setEndChanage("文化程度："+findpeople.getEducation());
                tPeopleLogEntity.setPeopleId(findpeople.getId());
                tPeopleLogEntity.setCreateUser(tApplyRecordEntity.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeopleCopyEntity.getSchool() &&!tPeopleCopyEntity.getSchool().equals(tPeopleEntity.getSchool())) {
                tPeopleLogEntity.setFirstChanage("毕业学校："+tPeopleEntity.getSchool());
                tPeopleLogEntity.setEndChanage("毕业学校："+findpeople.getSchool());
                tPeopleLogEntity.setPeopleId(findpeople.getId());
                tPeopleLogEntity.setCreateUser(tApplyRecordEntity.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeopleCopyEntity.getMajor() &&!tPeopleCopyEntity.getMajor().equals(tPeopleEntity.getMajor())) {
                tPeopleLogEntity.setFirstChanage("专业："+tPeopleEntity.getMajor());
                tPeopleLogEntity.setEndChanage("专业："+findpeople.getMajor());
                tPeopleLogEntity.setPeopleId(findpeople.getId());
                tPeopleLogEntity.setCreateUser(tApplyRecordEntity.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeopleCopyEntity.getEducationTime() &&!tPeopleCopyEntity.getEducationTime().equals(tPeopleEntity.getEducationTime())) {
                tPeopleLogEntity.setFirstChanage("毕业时间："+tPeopleEntity.getEducationTime());
                tPeopleLogEntity.setEndChanage("毕业时间："+findpeople.getEducationTime());
                tPeopleLogEntity.setPeopleId(findpeople.getId());
                tPeopleLogEntity.setCreateUser(tApplyRecordEntity.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeopleCopyEntity.getSolo() &&!tPeopleCopyEntity.getSolo().equals(tPeopleEntity.getSolo())) {
                tPeopleLogEntity.setFirstChanage("独生子女："+tPeopleEntity.getSolo());
                tPeopleLogEntity.setEndChanage("独生子女："+findpeople.getSolo());
                tPeopleLogEntity.setPeopleId(findpeople.getId());
                tPeopleLogEntity.setCreateUser(tApplyRecordEntity.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeopleCopyEntity.getCadre() &&!tPeopleCopyEntity.getCadre().equals(tPeopleEntity.getCadre())) {
                tPeopleLogEntity.setFirstChanage("干部子女："+tPeopleEntity.getCadre());
                tPeopleLogEntity.setEndChanage("干部子女："+findpeople.getCadre());
                tPeopleLogEntity.setPeopleId(findpeople.getId());
                tPeopleLogEntity.setCreateUser(tApplyRecordEntity.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeopleCopyEntity.getHomeType() &&!tPeopleCopyEntity.getHomeType().equals(tPeopleEntity.getHomeType())) {
                tPeopleLogEntity.setFirstChanage("家庭情况："+tPeopleEntity.getHomeType());
                tPeopleLogEntity.setEndChanage("家庭情况："+findpeople.getHomeType());
                tPeopleLogEntity.setPeopleId(findpeople.getId());
                tPeopleLogEntity.setCreateUser(tApplyRecordEntity.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            }
         if(null !=tPeopleCopyEntity.getFireIdcard() &&!tPeopleEntity.getFireIdcard().equals(tPeopleCopyEntity.getFireIdcard())) {
            tPeopleLogEntity.setFirstChanage("消防员证"+tPeopleEntity.getFireIdcard());
            tPeopleLogEntity.setEndChanage("消防员证"+findpeople.getFireIdcard());
            tPeopleLogEntity.setPeopleId(findpeople.getId());
            tPeopleLogEntity.setCreateUser(tApplyRecordEntity.getCreateUser());
            tPeopleLogEntity.setCreateTime(new Date());
            tPeopleLogService.save(tPeopleLogEntity);
        }
            if(null !=tPeopleCopyEntity.getBlood() &&!tPeopleCopyEntity.getBlood().equals(tPeopleEntity.getBlood())) {
                tPeopleLogEntity.setFirstChanage("血型："+tPeopleEntity.getBlood());
                tPeopleLogEntity.setEndChanage("血型："+findpeople.getBlood());
                tPeopleLogEntity.setPeopleId(findpeople.getId());
                tPeopleLogEntity.setCreateUser(tApplyRecordEntity.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            }
            if(null !=tPeopleCopyEntity.getHight() &&!tPeopleCopyEntity.getHight().equals(tPeopleEntity.getHight())) {
                tPeopleLogEntity.setFirstChanage("身高："+tPeopleEntity.getHight());
                tPeopleLogEntity.setEndChanage("身高："+findpeople.getHight());
                tPeopleLogEntity.setPeopleId(findpeople.getId());
                tPeopleLogEntity.setCreateUser(tApplyRecordEntity.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            }
        if(null !=tPeopleCopyEntity.getMarry() &&!tPeopleEntity.getMarry().equals(tPeopleCopyEntity.getMarry())) {
            tPeopleLogEntity.setFirstChanage("婚姻状况"+tPeopleEntity.getMarry());
            tPeopleLogEntity.setEndChanage("婚姻状况"+findpeople.getMarry());
            tPeopleLogEntity.setPeopleId(findpeople.getId());
            tPeopleLogEntity.setCreateUser(tApplyRecordEntity.getCreateUser());
            tPeopleLogEntity.setCreateTime(new Date());
            tPeopleLogService.save(tPeopleLogEntity);
        } if(null !=tPeopleCopyEntity.getMarryTime() &&!tPeopleEntity.getMarryTime().equals(tPeopleCopyEntity.getMarryTime())) {
            tPeopleLogEntity.setFirstChanage("结婚时间"+tPeopleEntity.getMarryTime());
            tPeopleLogEntity.setEndChanage("结婚时间"+findpeople.getMarryTime());
            tPeopleLogEntity.setPeopleId(findpeople.getId());
            tPeopleLogEntity.setCreateUser(tApplyRecordEntity.getCreateUser());
            tPeopleLogEntity.setCreateTime(new Date());
            tPeopleLogService.save(tPeopleLogEntity);
        } if(null !=tPeopleCopyEntity.getSpouse() &&!tPeopleEntity.getSpouse().equals(tPeopleCopyEntity.getSpouse())) {
            tPeopleLogEntity.setFirstChanage("配偶户籍"+tPeopleEntity.getSpouse());
            tPeopleLogEntity.setEndChanage("配偶户籍"+findpeople.getSpouse());
            tPeopleLogEntity.setPeopleId(findpeople.getId());
            tPeopleLogEntity.setCreateUser(tApplyRecordEntity.getCreateUser());
            tPeopleLogEntity.setCreateTime(new Date());
            tPeopleLogService.save(tPeopleLogEntity);
        } if(null !=tPeopleCopyEntity.getKids() &&!tPeopleEntity.getKids().equals(tPeopleCopyEntity.getKids())) {
            tPeopleLogEntity.setFirstChanage("生育情况"+tPeopleEntity.getKids());
            tPeopleLogEntity.setEndChanage("生育情况"+findpeople.getKids());
            tPeopleLogEntity.setPeopleId(findpeople.getId());
            tPeopleLogEntity.setCreateUser(tApplyRecordEntity.getCreateUser());
            tPeopleLogEntity.setCreateTime(new Date());
            tPeopleLogService.save(tPeopleLogEntity);
        } if(null !=tPeopleCopyEntity.getAddress() &&!tPeopleEntity.getAddress().equals(tPeopleCopyEntity.getAddress())) {
            tPeopleLogEntity.setFirstChanage("地址"+tPeopleEntity.getAddress());
            tPeopleLogEntity.setEndChanage("地址"+findpeople.getAddress());
            tPeopleLogEntity.setPeopleId(findpeople.getId());
            tPeopleLogEntity.setCreateUser(tApplyRecordEntity.getCreateUser());
            tPeopleLogEntity.setCreateTime(new Date());
            tPeopleLogService.save(tPeopleLogEntity);
        } if(null !=tPeopleCopyEntity.getSocialCard() &&!tPeopleEntity.getSocialCard().equals(tPeopleCopyEntity.getSocialCard())) {
            tPeopleLogEntity.setFirstChanage("社保卡"+tPeopleEntity.getSocialCard());
            tPeopleLogEntity.setEndChanage("社保卡"+findpeople.getSocialCard());
            tPeopleLogEntity.setPeopleId(findpeople.getId());
            tPeopleLogEntity.setCreateUser(tApplyRecordEntity.getCreateUser());
            tPeopleLogEntity.setCreateTime(new Date());
            tPeopleLogService.save(tPeopleLogEntity);
        }
            if(null !=tPeopleCopyEntity.getContractType() &&!tPeopleCopyEntity.getContractType().equals(tPeopleEntity.getContractType())) {
                tPeopleLogEntity.setFirstChanage("合同期限"+tPeopleEntity.getContractType());
                tPeopleLogEntity.setEndChanage("合同期限"+findpeople.getContractType());
                tPeopleLogEntity.setPeopleId(findpeople.getId());
                tPeopleLogEntity.setCreateUser(tApplyRecordEntity.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeopleCopyEntity.getSeniorityHistory() &&!tPeopleCopyEntity.getSeniorityHistory().equals(tPeopleEntity.getSeniorityHistory())) {
                tPeopleLogEntity.setFirstChanage("入职前工龄"+tPeopleEntity.getSeniorityHistory());
                tPeopleLogEntity.setEndChanage("入职前工龄"+findpeople.getSeniorityHistory());
                tPeopleLogEntity.setPeopleId(findpeople.getId());
                tPeopleLogEntity.setCreateUser(tApplyRecordEntity.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeopleCopyEntity.getSeniorityNow() &&!tPeopleCopyEntity.getSeniorityNow().equals(tPeopleEntity.getSeniorityNow())) {
                tPeopleLogEntity.setFirstChanage("本单位工龄"+tPeopleEntity.getSeniorityNow());
                tPeopleLogEntity.setEndChanage("本单位工龄"+findpeople.getSeniorityNow());
                tPeopleLogEntity.setPeopleId(findpeople.getId());
                tPeopleLogEntity.setCreateUser(tApplyRecordEntity.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeopleCopyEntity.getSeniorityTotal() &&!tPeopleCopyEntity.getSeniorityTotal().equals(tPeopleEntity.getSeniorityTotal())) {
                tPeopleLogEntity.setFirstChanage("总工龄"+tPeopleEntity.getSeniorityTotal());
                tPeopleLogEntity.setEndChanage("总工龄"+findpeople.getSeniorityTotal());
                tPeopleLogEntity.setPeopleId(findpeople.getId());
                tPeopleLogEntity.setCreateUser(tApplyRecordEntity.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeopleCopyEntity.getCallPhone() &&!tPeopleCopyEntity.getCallPhone().equals(tPeopleEntity.getCallPhone())) {
                tPeopleLogEntity.setFirstChanage("手机"+tPeopleEntity.getCallPhone());
                tPeopleLogEntity.setEndChanage("手机"+findpeople.getCallPhone());
                tPeopleLogEntity.setPeopleId(findpeople.getId());
                tPeopleLogEntity.setCreateUser(tApplyRecordEntity.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeopleCopyEntity.getFileNumber() &&!tPeopleCopyEntity.getFileNumber().equals(tPeopleEntity.getFileNumber())) {
                tPeopleLogEntity.setFirstChanage("档案号码"+tPeopleEntity.getFileNumber());
                tPeopleLogEntity.setEndChanage("档案号码"+findpeople.getFileNumber());
                tPeopleLogEntity.setPeopleId(findpeople.getId());
                tPeopleLogEntity.setCreateUser(tApplyRecordEntity.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeopleCopyEntity.getStrength() &&!tPeopleCopyEntity.getStrength().equals(tPeopleEntity.getStrength())) {
                tPeopleLogEntity.setFirstChanage("特长"+tPeopleEntity.getStrength());
                tPeopleLogEntity.setEndChanage("特长"+findpeople.getStrength());
                tPeopleLogEntity.setPeopleId(findpeople.getId());
                tPeopleLogEntity.setCreateUser(tApplyRecordEntity.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeopleCopyEntity.getInstructions() &&!tPeopleCopyEntity.getInstructions().equals(tPeopleEntity.getInstructions())) {
                tPeopleLogEntity.setFirstChanage("说明"+tPeopleEntity.getInstructions());
                tPeopleLogEntity.setEndChanage("说明"+findpeople.getInstructions());
                tPeopleLogEntity.setPeopleId(findpeople.getId());
                tPeopleLogEntity.setCreateUser(tApplyRecordEntity.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeopleCopyEntity.getPicture() &&!tPeopleCopyEntity.getPicture().equals(tPeopleEntity.getPicture())) {
            tPeopleLogEntity.setFirstChanage("图片"+tPeopleEntity.getPicture());
            tPeopleLogEntity.setEndChanage("图片"+findpeople.getPicture());
            tPeopleLogEntity.setPeopleId(findpeople.getId());
            tPeopleLogEntity.setCreateUser(tApplyRecordEntity.getCreateUser());
            tPeopleLogEntity.setCreateTime(new Date());
            tPeopleLogService.save(tPeopleLogEntity);
        }
            if(null !=tPeopleCopyEntity.getAccessories() &&!tPeopleCopyEntity.getAccessories().equals(tPeopleEntity.getAccessories())) {
                tPeopleLogEntity.setFirstChanage("附件"+tPeopleEntity.getAccessories());
                tPeopleLogEntity.setEndChanage("附件"+findpeople.getAccessories());
                tPeopleLogEntity.setPeopleId(findpeople.getId());
                tPeopleLogEntity.setCreateUser(tApplyRecordEntity.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeopleCopyEntity.getState() &&!tPeopleCopyEntity.getState().equals(tPeopleEntity.getState())) {
                tPeopleLogEntity.setFirstChanage("状态"+tPeopleEntity.getState());
                tPeopleLogEntity.setEndChanage("状态"+findpeople.getState());
                tPeopleLogEntity.setPeopleId(findpeople.getId());
                tPeopleLogEntity.setCreateUser(tApplyRecordEntity.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeopleCopyEntity.getEffective() &&!tPeopleCopyEntity.getEffective().equals(tPeopleEntity.getEffective())) {
                tPeopleLogEntity.setFirstChanage("有效性"+tPeopleEntity.getEffective());
                tPeopleLogEntity.setEndChanage("有效性"+findpeople.getEffective());
                tPeopleLogEntity.setPeopleId(findpeople.getId());
                tPeopleLogEntity.setCreateUser(tApplyRecordEntity.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeopleCopyEntity.getPeopleType() &&!tPeopleCopyEntity.getPeopleType().equals(tPeopleEntity.getPeopleType())) {
                tPeopleLogEntity.setFirstChanage("人员类型"+tPeopleEntity.getPeopleType());
                tPeopleLogEntity.setEndChanage("人员类型"+findpeople.getPeopleType());
                tPeopleLogEntity.setPeopleId(findpeople.getId());
                tPeopleLogEntity.setCreateUser(tApplyRecordEntity.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            }
        }else{ //不通过
            //生成审批记录表信息
            tApplyRecordEntity.setApplyTime(new Date());
            tApplyRecordEntity.setState("2");
            tApplyRecordService.updateById(tApplyRecordEntity);

            //删除临时表信息
            tPeopleCopyDao.delete(new QueryWrapper<TPeopleCopyEntity>().eq("id", tApplyEntity.getDataId()));
            //生成通知信息
            //插入通知表，提醒相关人员
            TPeopleNoticeEntity tPeopleNoticeEntity=new TPeopleNoticeEntity();
            tPeopleNoticeEntity.setPeopleId(tApplyEntity.getDataId());
            tPeopleNoticeEntity.setName(tApplyRecordEntity.getApplyUser());
            tPeopleNoticeEntity.setChanageAfterClasses("申请修改不通过");
            tPeopleNoticeService.save(tPeopleNoticeEntity);

        }

        return R.ok();
    }


}